<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" close="true">
        <span aria-hidden="true">×</span>
    </button>
    <h4 class="modal-title">
        <span class="fa fa-legal"></span>&nbsp;添加摄像头
    </h4>
</div>
<style>


</style>
<div class="modal-body">
    <div class="new-content">
        <form name="add_form" class="form-horizontal layui-form" id="frm">
            <div class="form-group">
                <label class="col-sm-2 control-label">*小区名称:</label>
                <div class="col-sm-8">
                    <select name="community_id" lay-verify="streetCode" lay-filter="streetCode" class="select">
                        <option>请选择小区</option>
                        {volist name="community" id="vo"}
                        <option value="{$vo.id}" {if isset($detail.community_id) && $detail.community_id eq $vo.id} selected {/if}>{$vo.propertyName}</option>
                        {/volist}
                    </select>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-2 control-label">*通道名称:</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="deviceName" value="{$detail.deviceName|default=''}" placeholder="设备名称">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">*设备序列号:</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="deviceSerial" value="{$detail.deviceSerial|default=''}" placeholder="设备序列号">
                </div>
            </div>

            {if isset($detail) && !empty($detail)}
                <div class="form-group">
                    <label class="col-sm-2 control-label">*通道号:</label>
                    <div class="col-sm-8">
                        <input type="number" class="form-control"  name="channelNo" value="{$detail.channelNo|default=''}" placeholder="通道号">
                    </div>
                </div>
            {else/}
                <div class="form-group">
                    <label class="col-sm-2 control-label">*通道号:</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control"  name="channelNo" placeholder="通道号（多个分号隔开）">
                    </div>
                </div>
            {/if}

            <input type="hidden" name="id" value="{$detail.id|default=''}">
            <div class="modal-footer">
                <button type="button" class="btn btn-default btn-sm" close="true">关闭</button>
                <button type="button" class="btn btn-primary btn-sm" id="upload">保存</button>
            </div>
        </form>
    </div>

</div>

<script>
    layui.use(['form'], function() {
        var form = layui.form
            , layer = layui.layer;
        $("#upload").click(function(){
            var formData = new FormData($( "#frm" )[0]);
            console.log(formData);
            $.ajax({
                url: "{:URL('wuye/monitor/save')}",
                type: 'POST',
                data: formData,
                async: false,
                cache: false,
                contentType: false,
                processData: false,
                success: function (res) {
                    if(res.code){
                        layer.alert(res.msg);
                    }else{
                        window.location.href = '/wuye/monitor/index';
                    }
                }
            });
        })
        layui.form.render('select');
        form.render();

    });



</script>